package com.gree.changying.server.network.eventbus;

/**
 * Create by 游德禄 on 2019-9-25
 */
final class Subscription {
    final Object subscriber;
    final SubscriberMethod subscriberMethod;
    final int priority;
    volatile boolean active;

    Subscription(Object subscriber, SubscriberMethod subscriberMethod, int priority) {
        this.subscriber = subscriber;
        this.subscriberMethod = subscriberMethod;
        this.priority = priority;
        this.active = true;
    }

    public boolean equals(Object other) {
        if (!(other instanceof Subscription)) {
            return false;
        } else {
            Subscription otherSubscription = (Subscription)other;
            return this.subscriber == otherSubscription.subscriber && this.subscriberMethod.equals(otherSubscription.subscriberMethod);
        }
    }

    public int hashCode() {
        return this.subscriber.hashCode() + this.subscriberMethod.methodString.hashCode();
    }
}
